<%@ tag language="java" pageEncoding="UTF-8" body-content="empty" trimDirectiveWhitespaces="true"%>
<%@ attribute name="name" type="java.lang.String" required='true' description="表单name"%>
<%@ attribute name="id" type="java.lang.String" required='true' description="id"%>
<%@ attribute name="dateFormat" type="java.lang.String" required="true" description="日期格式，如：yyyy-MM-dd hh:ii：年月日时分，yyyy-MM-dd：年月日，hh:ii：时分"%>
<%@ attribute name="dateType" type="java.lang.String" required="true" description="确定你的类型，可选3种类型：date,datetime,time"%>
<%@ attribute name="readonly" type="java.lang.Boolean" description="设置是否允许用户手动输入，default = false"%>
<%@ attribute name="defaultNow" type="java.lang.Boolean" description="设置是否默认为当前时间，default = false"%>
<%@ attribute name="value" type="java.lang.String" description="设置默认时间，default = false"%>
<%@ attribute name="className" type="java.lang.String" description="设置css class"%>
<div class="input-group date m-datepicker col-md-12 col-sm-12 ${className }" data-link-field="dtp_input1">
	<input name="${name}" id="${id}" class="form-control m-datepicker-input" type="text">
	<span class="input-group-addon"><span class="icon-remove"></span></span>
	<span class="input-group-addon"><span class="icon-th"></span></span>
</div>
<script type="text/javascript">
(function(){
	var zuiFormat = "${dateFormat}".toLowerCase();
	var datepickerOptions = null;
	if("${dateType}"=="date"){
		datepickerOptions ={
			language:  "zh-CN",
			weekStart: 1,
			todayBtn:  1,
			autoclose: 1,
			todayHighlight: 1,
			startView: 2,
			minView: 2,
			forceParse: 0,
		    format: zuiFormat
		};
	}else if("${dateType}"=="datetime"){
		datepickerOptions ={
			weekStart: 1,
		    todayBtn:  1,
		    autoclose: 1,
		    todayHighlight: 1,
		    startView: 2,
		    forceParse: 0,
		    showMeridian: 1,
		    format: zuiFormat
		};
	}else if("${dateType}"=="time"){
		datepickerOptions ={
		    language:  "zh-CN",
		    weekStart: 1,
		    todayBtn:  1,
		    autoclose: 1,
		    todayHighlight: 1,
		    startView: 1,
		    minView: 0,
		    maxView: 1,
		    forceParse: 0,
		    format: zuiFormat
		};
	}
	Logger.debug("datepicker.tag => datepickerOptions => " + JSON.stringify(datepickerOptions));
	var classOption = {
		'date':'form-date',
		'datetime':'form-datetime',
		'time':'form-time'
	};
	$("input[name='${name}']").closest(".m-datepicker").addClass(classOption['${dateType}']);
	$("input[name='${name}']").closest(".m-datepicker").datetimepicker(datepickerOptions);
	if('${defaultNow}'=='true'){
		zuiFormat = zuiFormat.replace(/ii/g,'mm').replace('yyyy-mm-dd','yyyy-MM-dd');
		var nowstr = new Date().format(zuiFormat);
		$("#${id}").attr({
			"data-date":nowstr,
			'value':nowstr});
	}
	if('${value}'!=''){
		var value = "${value}".toLowerCase();
		$("#${id}").attr({
			"data-date":value,
			'value':value});
		/* $("input[name='${name}']").val(value); */
	}
	if("${readonly}"=="true"){
		/* $("input[name='${name}']").attr("readonly","readonly"); */
		$("#${id}").attr("readonly","readonly");
	}
})();
</script>